const { sequelize } = require("@core/db");
const { Sequelize, Model } = require("sequelize");

class Rebate extends Model {}

Rebate.init(
  {
    rebate_id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    pid: {
      type: Sequelize.INTEGER,
      comment: "上级id",
    },
    uid: {
      type: Sequelize.INTEGER,
      comment: "用户id",
    },
    admin_id: {
      type: Sequelize.STRING,
      comment: "管理员id",
    },
    user_point_id: {
      type: Sequelize.INTEGER,
      comment: "用户积分id",
    },
    product_id: {
      type: Sequelize.INTEGER,
      comment: "消费产品id",
    },
    remark: {
      type: Sequelize.STRING,
      comment: "备注",
    },
    rebate_money: {
      type: Sequelize.DECIMAL(10, 2),
      comment: "金额",
    },
    rr_id: {
      type: Sequelize.INTEGER,
      comment: "结算记录id",
    },
  },
  {
    sequelize,
    tableName: "rebate",
  }
);

class RebateRecord extends Model {}
// 结算记录
RebateRecord.init(
  {
    rr_id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    rr_money: {
      type: Sequelize.STRING,
      comment: "金额",
    },
    uid: {
      type: Sequelize.INTEGER,
      comment: "用户id",
    },
  },
  {
    sequelize,
    tableName: "rebate_record",
  }
);

module.exports = {
  Rebate,
  RebateRecord,
};
